#ifndef __V_GLOBAL_H
#define __V_GLOBAL_H

//typedef signed char vint8;
//typedef unsigned char vuint8;
//typedef short vint16;
//typedef unsigned short vuint16;
//typedef int vint32;
//typedef unsigned int vuint32;
//typedef long long vint64;
//typedef unsigned long long vuint64;
//typedef float vfloat;
//typedef double vdouble;

//typedef enum
//{
//    v_false = 0,
//    v_true = !v_false
//}vbool;

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

/** 定义句柄 */
#define V_DECLEAR_HANDLE(name) struct name##__{int unused;};typedef struct name##__ *name


#ifdef __cplusplus
#define C_API   extern "C"
#else
#define C_API
#endif

#ifdef __cplusplus
#define C_API_BEGIN extern "C" {
#define C_API_END    }
#else
#define C_API_BEGIN
#define C_API_END
#endif

#if defined(__GNUC__)

#define section_(x)     __attribute__((section(x)))
#define unused_(x)      __attribute__((unused))
#define used_           __attribute__((used))
#define align_(n)       __attribute__((aligned(n)))
#define weak_           __attribute__((weak))
#define inline_         static inline

#define LIKELY(x)           (__builtin_expect(!!(x), 1))
#define UNLIKELY(x)         (__builtin_expect(!!(x), 0))

#define SWAP(a, b)          \
    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)

#endif

#define MIN2(a, b)          ((a) > (b) ? (b) : (a))
#define MAX2(a, b)          ((a) > (b) ? (a) : (b))
#define ABS(x)              ((x) >= 0 ? (x) : -(x))

#define ARRAY_SIZE(a)       (sizeof(a) / sizeof(a[0]))

#define ALIGN2(x, a)	(((x) + (a) - 1) & ~((a) - 1))

#define ROUND(x)    ((int)((x)+0.5))    //四舍五入

//消除警告
#define UNUSED(x)       (void)x
#endif
